package com.yanqu.road.server.logic.activity.condition.pageant;

import com.yanqu.road.entity.activity.ActivityConditionInfo;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.task.TaskModule;
import com.yanqu.road.server.logic.activity.BaseActivityData;
import com.yanqu.road.server.logic.activity.condition.BaseNewRankActivityCondition;

import java.math.BigInteger;

/**
 * 选美大会总分分数冲榜
 */
public class PageantTotalScoreCrossRankCondition extends BaseNewRankActivityCondition {

    public PageantTotalScoreCrossRankCondition(ActivityInfo activityInfo, ActivityConditionInfo activityConditionInfo, BaseActivityData baseActivityData) {
        super(activityInfo, activityConditionInfo, baseActivityData);
    }

    @Override
    public void addTrigger(GamePlayer player) {
        player.getModule(TaskModule.class).getGameEvent().addListener(eGamePlayerEventType.PageantTotalScoreCrossRank.getValue(), handle);
    }

    @Override
    public void removeTrigger(GamePlayer player) {
        player.getModule(TaskModule.class).getGameEvent().removeListener(eGamePlayerEventType.PageantTotalScoreCrossRank.getValue(), handle);
    }

    @Override
    protected void player_BoardLevelHandle(Object object) {
        int score = (int)object;
        setValue(BigInteger.valueOf(score));
        //重新生成排行榜
        rankChange();
    }
}
